﻿using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using TfsAlert.Core;

namespace TfsAlert.Core.Activities
{
	public partial class RelayOn: Activity
	{
		public RelayOn()
		{
			InitializeComponent();
		}

        public static DependencyProperty RelayPortProperty = DependencyProperty.Register( "RelayPort", typeof( int ), typeof( RelayOn ) );

        [DescriptionAttribute( "RelayPort" )]
        [CategoryAttribute( "RelayPort Category" )]
        [BrowsableAttribute( true )]
        [DesignerSerializationVisibilityAttribute( DesignerSerializationVisibility.Visible )]
        public int RelayPort
        {
            get
            {
                return ( (int)( base.GetValue( RelayOn.RelayPortProperty ) ) );
            }
            set
            {
                base.SetValue( RelayOn.RelayPortProperty, value );
            }
        }

        protected override ActivityExecutionStatus Execute( ActivityExecutionContext executionContext )
        {
            RelayIO relay = new RelayIO();

            relay.Open();
            relay.TurnRelayOn( this.RelayPort );
            relay.Close();

            return ActivityExecutionStatus.Closed;
        }

	}
}
